# -*- coding:utf-8 -*-

# the python module

# the django module
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext

from django import forms
from django.http import Http404


from django.utils.translation import ugettext as _
from django.views.decorators.cache import never_cache
from django.conf import settings


# the SPF module


def signup(request):
    """
    signup page
    """
    return render_to_response("users/signup.html", { "current_title" : _("signup")}, RequestContext(request))

def docs(request):
    """
    docs
    """
    return render_to_response("users/docs.html", { "current_title" : _("notes about cs(in Chinese)")}, RequestContext(request))

def about(request):
    """
    about me
    """
    return render_to_response("aboutme.html", { "current_title" : _("about me")}, RequestContext(request))

def index(request):
    """
    about me
    """
    return render_to_response("users/index.html", { "current_title" : _("homepage")}, RequestContext(request))

from django.utils.translation import check_for_language 
from django import http

def set_language(request, lang_code): 
    """ 
    Patched for Get method 
    """ 
    next = request.REQUEST.get('next', None) 
    if not next: 
        next = '/' 
    response = http.HttpResponseRedirect(next) 
    if lang_code and check_for_language(lang_code): 
        if hasattr(request, 'session'): 
            request.session['django_language'] = lang_code 
        else: 
            response.set_cookie(settings.LANGUAGE_COOKIE_NAME, 
lang_code) 
    return response 
